package com.school.fuyuan.business.mapper;

import com.school.fuyuan.business.model.po.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author zrhong
 * @version 1.0
 * @date 2019/3/7 23:05
 * @description
 */
@Mapper
public interface UserMapper {

    User getUser(String userId);

    int updatePassword(@Param("userId") String userId,
                       @Param("newPassword") String newPassword);

    int register(User user);

    List<User> getUsers(@Param("pageMin") int pageMin,@Param("pageSize") int pageSize);

    @Update("update user_role set role_id=#{roleId} where user_id=#{userId}")
    void updateRole(@Param("userId") String userId, @Param("roleId") String roleId);

    User getUserByMobile(String mobile);

    List<String> getApptIds(String userId);

    @Select("select count(1) from sys_user")
    int getUsersCount();

    @Insert("insert into user_role(user_id,role_id) values(#{userId},#{roleId})")
    void addUserRole(@Param("userId") String userId, @Param("roleId") String roleId);

    @Delete("delete from sys_user where user_id=#{userId}")
    void deleteUser(Integer userId);

    @Delete("delete from user_role where user_id=#{userId}")
    void deleteUserRole(Integer userId);

    List<User> getUsersByUserIds(@Param("userIds") List<String> userIds);
}
